package com.indeep.user;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {
    private Object target;
    
    public MyInvocationHandler(Object target) {
        this.target = target;
    }
    
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 执行额外的逻辑
        System.out.println("Before method " + method.getName());
        
        // 调用被代理对象的方法
        Object result = method.invoke(target, args);
        
        // 执行额外的逻辑
        System.out.println("After method " + method.getName());
        
        return result;
    }
}
